<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>书城</title>
    <link rel="stylesheet" href="../css/main.css"/>
</head>

<body>
<!--顶部-->
<div class="top">
    <div class="top_center">
        <ul class="top_bars">
            <c:choose>
                <c:when test="${!empty SESSION_USERNAME}">
                    <li style="margin-top: 3px; color: red">${SESSION_USERNAME}</li>
                    <li><a href="${pageContext.request.contextPath}/logout">退出</a>|</li>
                </c:when>
                <c:otherwise>
                    <li><a href="${pageContext.request.contextPath}/pages/login.jsp">登录</a></li>
                </c:otherwise>
            </c:choose>
            <c:set var="show" value="${SESSION_LEVEL}"/>
            <c:if test="${show eq true}">
                <li><a href="${pageContext.request.contextPath}/admin/queryAllOrder" style="color: #d12f2f">
                    全部订单</a>|
                </li>
            </c:if>
            <li><a href="${pageContext.request.contextPath}/queryMyOrder">我的订单<span class="jt_down"></span></a>||</li>
            <li><a href="#">关注我们<span class="jt_down"></span></a>|</li>
            <li><a href="#">网站导航<span class="jt_down"></span></a></li>
        </ul>
    </div>
</div>

<!--头部-->
<div class="header3">
    <a href="#"><img src="../images/logo.png"></a>
    <div class="h3_center">
        <div class="search_box">
            <input type="text" id="bookNameInput" name="bookName" required>
            <span onclick="search(document.getElementById('bookNameInput').value)">搜索</span>
        </div>

    </div>
    <div class="h3_right">
        <div class="tsc">
            <a href="#" onclick="cart()" style="color: limegreen">->去购物车结算</a>
            <span class="sj_right"></span>
        </div>
    </div>
</div>


<!--头部导航-->
<div class="nav_top">
    <div class="nav_top_center">
        <div>
            全部图书分类:
        </div>
        <ul>
            <c:forEach items="${cList}" var="cli">
                <li><a href="#" onclick="find('${cli.id}')">${cli.name}</a></li>
            </c:forEach>


            <c:set var="show" value="${SESSION_LEVEL}"/>
            <c:if test="${show eq true}">
                <li>
                    <button type="submit" onclick="tianjiafenlei()"
                            style=" border: 2px solid #d12f2f;border-radius: 5px; cursor: pointer"  >
                        添加分类
                    </button>
                </li>
                <li>
                <button type="submit" onclick="tianjiatushu()"
                        style=" border: 2px solid #d12f2f;border-radius: 5px; cursor: pointer"  >
                    添加图书
                </button>
                </li>

            </c:if>

        </ul>
    </div>
</div>


<!-- 主体部分 -->

<c:forEach items="${list}" var="li">
    <div class="product">
        <img src="${li.image}" alt="点击查看详情" onclick="getDetail('${li.id}')">
        <h2>${li.name}</h2>
        <p>价格:${li.price}</p>
        <button onclick="add('${li.id}')">加入购物车</button>

        <c:set var="show" value="${SESSION_LEVEL}"/>
        <c:if test="${show eq true}">
                <button type="submit" onclick="shanchu('${li.id}')"
                        style=" border: 2px solid #d12f2f;border-radius: 5px;" >
                    删除图书
                </button>
        </c:if>

    </div>
</c:forEach>



<!--脚部-->
<div class="footer3">
    <div class="f3_top">
        <div class="f3_center">
            <div class="ts1">品目繁多 愉悦购物</div>
            <div class="ts2">正品保障 天天低价</div>
            <div class="ts3">极速物流 特色定制</div>
            <div class="ts4">优质服务 以客为尊</div>
        </div>
    </div>
    <div class="f3_middle">
        <ul class="f3_center">
            <li class="f3_mi_li01">
                <h1>购物指南</h1>
                <p>常见问题</p>
                <p>找回密码</p>
                <p>会员介绍</p>
                <p>购物演示</p>
            </li>
            <li class="f3_mi_li01">
                <h1>配送方式</h1>
                <p>常见问题</p>
                <p>找回密码</p>
                <p>会员介绍</p>
                <p>购物演示</p>
            </li>
            <li class="f3_mi_li01">
                <h1>支付方式</h1>
                <p>常见问题</p>
                <p>找回密码</p>
                <p>会员介绍</p>
                <p>购物演示</p>
            </li>
            <li class="f3_mi_li01">
                <h1>售后服务</h1>
                <p>常见问题</p>
                <p>找回密码</p>
                <p>会员介绍</p>
                <p>购物演示</p>
            </li>
            <li class="f3_mi_li01">
                <h1>服务保障</h1>
                <p>常见问题</p>
                <p>找回密码</p>
                <p>会员介绍</p>
                <p>购物演示</p>
            </li>
            <li class="f3_mi_li06">
                <h1>客服中心</h1>
                <img src="../images/kf.png" width="80px" height="80px">
                <p>抢红包、疑问咨询、优惠活动</p>
            </li>
        </ul>
    </div>
    <div class="f3_bottom">
        <p class="f3_links">
            <a href="#">关于我们</a>|
            <a href="#">联系我们</a>|
            <a href="#">友情链接</a>|
            <a href="#">供货商入驻</a>
        </p>
        <p>无ADC备20021001号-666 kkkkkk.com版权所有 安师软件666科技无限公司 </p>
    </div>
</div>

<script>

    function add(id){
        <c:if test="${SESSION_ISLOGIN eq true}">
            window.location.href="${pageContext.request.contextPath}/user/addOne?id="+id;
        </c:if>
        <c:if test="${SESSION_ISLOGIN eq null}">
        window.alert("请先登录");
        </c:if>
    }

    function cart(){
        <c:if test="${SESSION_ISLOGIN eq true}">
        window.location.href="${pageContext.request.contextPath}/user/queryShopCart"
        </c:if>
        <c:if test="${SESSION_ISLOGIN eq null}">
        window.alert("请先登录");
        </c:if>
    }

    function getDetail(id){
        window.location.href="${pageContext.request.contextPath}/getDetail?id="+id;
    }

    function find(a){
        window.location.href="${pageContext.request.contextPath}/findByCategoryId?cid="+a;
    }

    function search(bookName){
        window.location.href="${pageContext.request.contextPath}/findByKeyWord?bookName="+bookName;
    }

    function tianjiatushu(){
        window.location.href="${pageContext.request.contextPath}/pages/tianjia.jsp";
    }
    function tianjiafenlei(){
        /*window.location.href="${pageContext.request.contextPath}/pages/tianjia2.jsp";*/
    }
    function shanchu(id){
        window.location.href="${pageContext.request.contextPath}/admin/deleteById?id="+id;
    }

</script>

</body>
</html>
